using UnityEngine;
using System.Collections;

public class AtlasManager : MonoBehaviour 
{
	public static Texture2D globalTexture;
	public static Rect[] rects;
    private Texture2D[] textures;
    private Texture2D[] textures2;
	public static Material globalMaterial;
	
	public void Awake()
	{
        string[] files = new string[]
        {
            "Bg_Opening",
            "Bg_Menu",
            "Bg_Credits",
            "Bg_Victory",
            "Bg_Defeat",
            "Horse_1",
            "Horse_2",
            "Horse_3",
            "Horse_4",
            "Button_Play",
            "Button_Credits",
            "Button_Instructions"
        };

		textures = new Texture2D[files.Length];
		
		for(var i = 0; i  < files.Length ; i++)
		{
			this.textures[i] = (Texture2D)Resources.Load("Textures/" + files[i]);
		}
                     
		globalTexture = AtlasTextures.Create(this.textures, out rects);
				
		globalMaterial = new Material((Shader)Resources.Load("Shader/Basic2D"));
		globalMaterial.mainTexture = globalTexture;
	}
}
